import {useDispatch,useSelector} from 'react-redux'
import {useEffect} from 'react'
import {getShopcartListAsync} from '../store/reducers/shopcart'
import {IShopcartModuleState} from '../types'
import {useAppDispatch,useAppSelector} from '../store/hooks'
export default function Shopcart() {
  
  
  const dispatch=useAppDispatch()
  let list=useAppSelector((state:IShopcartModuleState)=>{
    return state.shopcart.rows
  })
  useEffect(()=>{
    dispatch(getShopcartListAsync())
  },[])
  console.log('list',list);
  return (
    <div>
      <h1>购物车</h1>
      <ul>
        {
          list.map(item=><li key={item._id}>{item.name}</li>)
        }
      </ul>
    </div>
  )
}
